home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / distutils / command / bdist.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  4.6 KB  |  126 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. """distutils.command.bdist
  5.  
  6. Implements the Distutils 'bdist' command (create a built [binary]
  7. distribution)."""
  8. __revision__ = '$Id: bdist.py 62197 2008-04-07 01:53:39Z mark.hammond $'
  9. import os
  10. from types import *
  11. from distutils.core import Command
  12. from distutils.errors import *
  13. from distutils.util import get_platform
  14.  
  15. def show_formats():
  16.     '''Print list of available formats (arguments to "--format" option).
  17.     '''
  18.     FancyGetopt = FancyGetopt
  19.     import distutils.fancy_getopt
  20.     formats = []
  21.     for format in bdist.format_commands:
  22.         formats.append(('formats=' + format, None, bdist.format_command[format][1]))
  23.     
  24.     pretty_printer = FancyGetopt(formats)
  25.     pretty_printer.print_help('List of available distribution formats:')
  26.  
  27.  
  28. class bdist(Command):
  29.     description = 'create a built (binary) distribution'
  30.     user_options = [
  31.         ('bdist-base=', 'b', 'temporary directory for creating built distributions'),
  32.         ('plat-name=', 'p', 'platform name to embed in generated filenames (default: %s)' % get_platform()),
  33.         ('formats=', None, 'formats for distribution (comma-separated list)'),
  34.         ('dist-dir=', 'd', 'directory to put final built distributions in [default: dist]'),
  35.         ('skip-build', None, 'skip rebuilding everything (for testing/debugging)')]
  36.     boolean_options = [
  37.         'skip-build']
  38.     help_options = [
  39.         ('help-formats', None, 'lists available distribution formats', show_formats)]
  40.     no_format_option = ('bdist_rpm',)
  41.     default_format = {
  42.         'posix': 'gztar',
  43.         'nt': 'zip',
  44.         'os2': 'zip' }
  45.     format_commands = [
  46.         'rpm',
  47.         'gztar',
  48.         'bztar',
  49.         'ztar',
  50.         'tar',
  51.         'wininst',
  52.         'zip']
  53.     format_command = {
  54.         'rpm': ('bdist_rpm', 'RPM distribution'),
  55.         'zip': ('bdist_dumb', 'ZIP file'),
  56.         'gztar': ('bdist_dumb', "gzip'ed tar file"),
  57.         'bztar': ('bdist_dumb', "bzip2'ed tar file"),
  58.         'ztar': ('bdist_dumb', 'compressed tar file'),
  59.         'tar': ('bdist_dumb', 'tar file'),
  60.         'wininst': ('bdist_wininst', 'Windows executable installer'),
  61.         'zip': ('bdist_dumb', 'ZIP file') }
  62.     
  63.     def initialize_options(self):
  64.         self.bdist_base = None
  65.         self.plat_name = None
  66.         self.formats = None
  67.         self.dist_dir = None
  68.         self.skip_build = 0
  69.  
  70.     
  71.     def finalize_options(self):
  72.         if self.plat_name is None:
  73.             if self.skip_build:
  74.                 self.plat_name = get_platform()
  75.             else:
  76.                 self.plat_name = self.get_finalized_command('build').plat_name
  77.         
  78.         if self.bdist_base is None:
  79.             build_base = self.get_finalized_command('build').build_base
  80.             self.bdist_base = os.path.join(build_base, 'bdist.' + self.plat_name)
  81.         
  82.         self.ensure_string_list('formats')
  83.         if self.formats is None:
  84.             
  85.             try:
  86.                 self.formats = [
  87.                     self.default_format[os.name]]
  88.             except KeyError:
  89.                 raise DistutilsPlatformError, "don't know how to create built distributions " + 'on platform %s' % os.name
  90.             except:
  91.                 None<EXCEPTION MATCH>KeyError
  92.             
  93.  
  94.         None<EXCEPTION MATCH>KeyError
  95.         if self.dist_dir is None:
  96.             self.dist_dir = 'dist'
  97.         
  98.  
  99.     
  100.     def run(self):
  101.         commands = []
  102.         for format in self.formats:
  103.             
  104.             try:
  105.                 commands.append(self.format_command[format][0])
  106.             continue
  107.             except KeyError:
  108.                 raise DistutilsOptionError, "invalid format '%s'" % format
  109.                 continue
  110.             
  111.  
  112.         
  113.         for i in range(len(self.formats)):
  114.             cmd_name = commands[i]
  115.             sub_cmd = self.reinitialize_command(cmd_name)
  116.             if cmd_name not in self.no_format_option:
  117.                 sub_cmd.format = self.formats[i]
  118.             
  119.             if cmd_name in commands[i + 1:]:
  120.                 sub_cmd.keep_temp = 1
  121.             
  122.             self.run_command(cmd_name)
  123.         
  124.  
  125.  
  126.